drop database lportal;
create database lportal;

go

use lportal;

create table PR_PRProduct (
	productId bigint not null primary key,
	productName nvarchar(75) null,
	serialNumber nvarchar(75) null,
	companyId bigint,
	groupId bigint
);

create table PR_PRRegistration (
	registrationId bigint not null primary key,
	prUserId bigint,
	datePurchased datetime null,
	howHear nvarchar(75) null,
	wherePurchased nvarchar(75) null,
	serialNumber nvarchar(75) null,
	productId bigint,
	companyId bigint,
	groupId bigint
);

create table PR_PRUser (
	prUserId bigint not null primary key,
	firstName nvarchar(75) null,
	lastName nvarchar(75) null,
	address1 nvarchar(75) null,
	address2 nvarchar(75) null,
	city nvarchar(75) null,
	state_ nvarchar(75) null,
	postalCode nvarchar(75) null,
	country nvarchar(75) null,
	phoneNumber nvarchar(75) null,
	email nvarchar(75) null,
	birthDate datetime null,
	gender nvarchar(75) null,
	userId bigint,
	companyId bigint,
	groupId bigint
);


create index IX_6EAAD412 on PR_PRProduct (companyId);
create index IX_DA9D3714 on PR_PRProduct (groupId);
create index IX_C7EFF736 on PR_PRProduct (groupId, productName);

create index IX_9BD618EC on PR_PRRegistration (groupId);
create index IX_98A73079 on PR_PRRegistration (groupId, datePurchased);
create index IX_397101C8 on PR_PRRegistration (groupId, prUserId);
create index IX_7F7BD0FD on PR_PRRegistration (groupId, serialNumber);

create index IX_98338272 on PR_PRUser (groupId, email);
create index IX_F0BBA40F on PR_PRUser (groupId, lastName);
create index IX_30F825D4 on PR_PRUser (groupId, userId);


